from sqlalchemy import Column, String, Integer, Text, ForeignKey
from sqlalchemy.orm import relationship

from  database import db


class Gateway(db.Model):
    id = Column(String(80), primary_key=True)
    screen_name = Column(String(120), nullable=False, doc='显示名称')
    type = Column(String(40), nullable=False, doc='网关类型', default='netpay')


class GatewayApi(db.Model):
    id = Column(Integer, primary_key=True, autoincrement=True)
    type = Column(String(30), doc='API类型', nullable=False)
    mode = Column(String(30), doc='调用方式，支持local', default='local', nullable=False)
    api_address = Column(String(120), doc='调用地址')
    extension = Column(Text, nullable=True, doc='扩展参数')
    gateway_id = Column(ForeignKey(Gateway.id), doc='所属网关')

    gateway = relationship(Gateway)
